-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Promotions: Deprecate Spree::PromotionRule#actionable and split rules that implement it #4321
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, though we could additionally deprecate the old rule if we want, right?
I've found a bug in the promotion system that makes line-item level rules do things we don't want them to do, so I'm marking this as draft until I've got the fix for that into a state that works. I'm likely also going to split the other two rules that have In this PR, I'm moving the |
b3d19a8
to
025581a
Compare
Hm, this got a bit bigger, but I think I got to a good place with this. I'm not deprecating the old rules; instead I leave them to do what their names and documentation and implementation say that they do: Check order eligibility. I added new rules for line item eligibility, and deprecated the use of This change gives meaning to the |
@jarednorman I've re-requested your review because this now contains a bunch more change than what you initially reviewed. |
c2dd392
to
b17739d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice work. Thank you for removing some of the confusing parts of the promotion system.
This rule is like "Product", but only applies to line items.
This rule is now only applicable to an order, and the naming should reflect that.
This spec allows me to show some of the weird things in the promotion system.
When we have a promotion with a line item rule that evaluates to ineligible for a line item, it will still call "actionable?" on that rule, which will evaluate to `true`, and create an adjustment on line items that will always be ineligible.
There was only one option for the match policy, so we can get rid of it.
This promotion rule shall replace the use of `actionable` on the `OptionValue` promotion rule.
This Rule can replace the use of `actionable?` on the taxon promotion rule.
Now that the Order, Taxon, and OptionValue rules only operate on orders, we need to add the respective line item rules to the promotions that need them.
This can now be accomplished using the LineItemActionable rule.
This can be done with the LineItemTaxon rule now.
This method now runs through promotion.eligible, which checks for the presence of actions.
We now have a few more promotion rules.
b17739d
to
2250f78
Compare
2250f78
to
2f5e451
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing
@kennyadsl would you mind having a look? Would this also be a change for 4.0? |
@mamhoff nope, if the public methods are deprecated and there's a clear transition path for who needs to change something in their codebase, I think we can marge this before 4.0 and only remove the deprecated parts in that major. Still, I didn't have time to review this PR yet, it's a bit large and requires some effort. Do you think there's a way or makes sense to split this into smaller PRs? |
@kennyadsl I don't think I can meaningfully split it into smaller pull requests. I'm depecrating an API here, and I'm providing a replacement. I'm also implementing this change across the promotion rules we have. This will necessarily take a few LOC, but splitting it up over multiple PRs I think would hurt readability and understandability of what's going on. Sorry! But do take your time. Best! |
Update: I had a quick look and this looks very good. I also asked some team members to check if this would impact the stores they are working on. I will approve once I have positive answers. In the meantime, thanks for the fantastic work, Martin! |
I think I do need to add more stuff from #4296 to this PR. Notably this will introduce bugs when re-calculating adjustments. |
Closing in favor of https://github.com/friendlycart/solidus_friendly_promotions/ |
The API of promotion rules is a bit strange: There's the
applicable
method, which looks like promotion rules could apply to line items as well as orders, and there'sactionable?
, which is likeeligible?
, but for line items.The
Product
rule is really two rules in one: An order rule (Does this order contain product x?) and a line item rule (Is this line item product x?).Same with the
Taxon
rule:Same with the
OptionValue
rule:What this PR does is
Spree::Promotion#line_item_actionable?
Spree::PromotionRule#actionable?
Checklist: